<template>
  <div>
    <el-table :data="noticesList" style="width: 100%">
      <el-table-column fixed prop="activity_id" label="活动编号" width="80"></el-table-column>
      <el-table-column prop="activity_type_name" label="活动类型名" width="100"></el-table-column>
      <el-table-column prop="activity_name" label="活动名" width="100"></el-table-column>
      <el-table-column prop="activity_description" label="活动描述" width="300"></el-table-column>
     <el-table-column fixed prop="activity_start_time" label="活动开始时间" width="80"></el-table-column>
      <el-table-column prop="activity_end_time" label="活动结束时间" width="100"></el-table-column>
      <el-table-column prop="signup_start_time" label="活动报名开始时间" width="100"></el-table-column>
      <el-table-column prop="signup_end_time" label="活动报名结束时间" width="100"></el-table-column>
       <el-table-column fixed prop="times" label="时间年" width="80"></el-table-column>
      <el-table-column prop="x_coordinate" label="活动地点x坐标" width="100"></el-table-column>
      <el-table-column prop="y_coordinate" label="活动地点y坐标" width="100"></el-table-column>
      <el-table-column prop="activity_place" label="活动地点" width="100"></el-table-column>
     
     <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  methods: {
    //搜索框输入搜索
    selectByNoticeNum() {
      const _this = this;
      var arr = [];
      axios({
        url:
          "http://localhost:8085/notices/web/select_notice_id?noticeNum=" +
          this.input.noticeNum,
        method: "get"
      }).then(function(res) {
        //将对象插入数组中
        var obj = res.data.data.selectdata;
        if (res.data.data.selectdata == null) {
          _this.noticesList = null;
        } else {
          arr.push({
            noticeNum: res.data.data.selectdata.noticeNum,
            noticeTitle: res.data.data.selectdata.noticeTitle,
            noticeContent: res.data.data.selectdata.noticeContent,
            noticeTime: res.data.data.selectdata.noticeTime
          });
          _this.noticesList = arr;
        }
      });
    },


    handleEdit(row) {
        console.log(row.activity_id)
      this.$router.push({
        path: "/updateactivityinfo",
        query: {
          activity_id: row.activity_id,
          //activity_type_name:row.activity_type_name
        }
      });
    },

    selectall() {
      const _this = this;
      axios({
        method: "post",
        url: "http://localhost:8085/tb-activityinfo/web/ActivityInfoList",
        data: {},
        headers: {}
      }).then(function(resp) {
        console.log(resp);

        _this.noticesList = resp.data.data.list;
      });
    },
    handleDelete(row) {
      const _this = this;
      console.log(row);
      axios({
        method: "put",
        url:
          "http://localhost:8085/tb-activityinfo/web/deleteActivityInfo?activity_id=" +
          row.activity_id,
        data: {},
        // headers: {
        //   // "Authorization":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOjksXCJ1c2VybmFtZVwiOm51bGwsXCJwaG9uZVwiOm51bGwsXCJhZGRyZXNzXCI6bnVsbCxcInJlbWFya1wiOm51bGwsXCJhdXRob3JpdHlcIjowLFwicGFzc3dvcmRcIjpcIjExMTExMVwiLFwiaGVhZF9wb3J0cmFpdFwiOm51bGwsXCJhcHBpZFwiOm51bGwsXCJzY29wZVwiOm51bGwsXCJzdGF0ZVwiOm51bGwsXCJ3aGV0aGVyX2RlbGV0ZVwiOm51bGwsXCJpZGVudGl0eV9pZFwiOlwiMTExMTExXCIsXCJjcmVhdGVfdGltZVwiOm51bGwsXCJ1cGRhdGVfdGltZVwiOm51bGwsXCJkZWxldGVfdGltZVwiOm51bGwsXCJvcmRlcnNMaXN0XCI6bnVsbH0iLCJleHAiOjE2MDUwOTU5OTZ9.TBEM_7Ti_Mm_UB9vD236lPstsqMjWAawBaBDFSp6oN0"
        //   Authorization: sessionStorage.getItem("token")
        // }
      }).then(function(resp) {
        if (resp.data.data.msg == "删除成功") {
          _this.$alert("《" + row.activity_id + "》确定删除！", "消息", {
            confirmButtonText: "确定",
            callback: action => {
              // _this.$router.push('/notices')
              window.location.reload();
            }
          });
        }
      });
    },

    
  },
  data() {
    return {
      show: true,
      input: {
        noticeNum: ""
      },
      noticesList: [
        {
        activity_id: "1",
        activity_type_name: "111",
        activity_name: "111",
        activity_description: "111",
        activity_start_time: "2021-04-05 20:08:13.211000",
        activity_end_time: "2021-06-05 20:08:13.211000",
        signup_start_time: "2021-04-05 20:08:13.211000",
        signup_end_time: "2021-06-05 20:08:13.211000",
        plan_num: 10,
        contact_name: null,
        contact_num: null,
        contact_email: null,
        create_time: 1617623615241,
        update_time: null,
        is_delete: 0,
        times: "2021",
        x_coordinate: "23.430891",
        y_coordinate: "113.172307",
        activity_place: "A3-201"
        },
        
      ]
    };
  },
  created() {
    // const _this = this;
    // axios({
    //   method: "get",
    //   url: "http://localhost:8085/notices/web/notice_list",
    //   data: {},
    //   headers: {}
    // }).then(function(resp) {
    //   console.log(resp);

    //   _this.noticesList = resp.data.data.list;
    // });
    this.selectall();
  }
};
</script>
<style>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>